//
//  PictureCell.m
//  AppPhoto
//
//  Created by heyong on 16/6/26.
//  Copyright © 2016年 ttsx. All rights reserved.
//
#define DEF_W(view) view.bounds.size.width
#define DEF_H(view) view.bounds.size.height
#define BTN_W 40

#import "PictureCell.h"
@implementation PictureCell
//懒加载
- (UIImageView *)pictureImg{
    if(_pictureImg==nil){
        _pictureImg=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, DEF_W(self.contentView), DEF_H(self.contentView))];
    }
    return _pictureImg;
}

- (void)setIsDel:(BOOL)isDel{
    if(isDel){
        [_selBtn setImage:[UIImage imageNamed:@"Close"] forState:UIControlStateNormal];
        [_selBtn setImage:[UIImage imageNamed:@"Close"] forState:UIControlStateSelected];
    }else{
        [_selBtn setImage:[UIImage imageNamed:@"selected_no"] forState:UIControlStateNormal];
        [_selBtn setImage:[UIImage imageNamed:@"selected_yes"] forState:UIControlStateSelected];
    }
}

- (UIButton *)selBtn{
    if(_selBtn==nil){
        _selBtn=[[UIButton alloc]initWithFrame:CGRectMake(DEF_W(self.contentView)-BTN_W, 0, BTN_W, BTN_W)];
        [_selBtn setImage:[UIImage imageNamed:@"selected_no"] forState:UIControlStateNormal];
        [_selBtn setImage:[UIImage imageNamed:@"selected_yes"] forState:UIControlStateSelected];
    }
    return _selBtn;
}

- (UIView *)imgLayerView{
    if(_imgLayerView==nil){
        _imgLayerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, DEF_W(self.contentView), DEF_H(self.contentView))];
        _imgLayerView.backgroundColor=[[UIColor whiteColor]colorWithAlphaComponent:0.5];
    }
    return _imgLayerView;
}

- (instancetype)initWithFrame:(CGRect)frame{
    if(self == [super initWithFrame:frame]){
        [self.contentView addSubview:self.pictureImg];
        [self.contentView addSubview:self.selBtn];
    }
    return self;
}

-(void)clickBtn:(UIButton *)sender{
    sender.selected = !sender.selected;
    if(self.clickBlock){
        self.clickBlock();
    }
}

@end


